<%-- 
    Document   : db4
    Created on : 2014/8/19, 下午 03:10:37
    Author     : gjun
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=
    DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb", "root", "root");
    Statement st =con.createStatement();
    String sql="select id,username,tel,birthday from person";
 
    
  %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>查詢</h1>
     <%
      ResultSet rs=st.executeQuery(sql);
      while(rs.next())//游標移動到下一組
      {
       String id=rs.getString("id");
       String username=rs.getString("username");
       String tel=rs.getString("tel");
       String birthday=rs.getString("birthday");
       out.println(id+","+username+","+tel+","+birthday+"<br>");
      }
      rs.close();
      st.close();
      con.close();
    %>
    </body>
</html>

